<!--
 * @Descripttion: damage报损报溢新增
 * @version:
 * @Author: cxguo
 * @Date: 2019-08-17 20:26:23
 * @LastEditors: cxguo
 * @LastEditTime: 2019-09-30 14:39:22
 -->
<template>
  <div>
    <el-form ref="roleData" :model="dataObj" :rules="rulesValidate" label-width="80px" size="small">
      <el-form-item label="角色名:" prop="roleName">
        <el-input v-model="dataObj.roleName" />
      </el-form-item>
      <el-form-item label="备注:" prop="remark">
        <el-input v-model="dataObj.remark" />
      </el-form-item>
      <!-- <el-form-item style="text-align: center">
        <el-button type="primary" size="medium" :loading="btnLoading.saveAdd" @click="btnSaveAdd">保存并新增</el-button>
        <el-button type="success" size="medium" :loading="btnLoading.save" @click="btnSave">保存</el-button>
      </el-form-item> -->
    </el-form>
  </div>
</template>

<script>
import { oftenuse } from '@/libs/mixins'
import { saveData as saveRoleData } from '@/api/sys/role'

export default {
  name: 'RoleSave',
  mixins: [oftenuse],
  props: {
  },
  data() {
    return {
      rulesValidate: {
        roleName: [
          { required: true, message: '请输入角色名称', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
  },
  watch: {
  },
  created() {
  },
  methods: {
    btnSaveAdd() {

    },
    btnSave() {

    },
    // api
    saveData() {
      const roleObj = this.dataObj
      return new Promise((resolve, reject) => {
        saveRoleData(roleObj).then(res => {
          if (!res.data.flag) {
            reject(res)
            return this.$notify.error({ title: '保存失败！', message: res.data.message || '' })
          } else {
            resolve(res)
            return this.$notify.success({ title: '保存成功！' })
          }
        }).catch(err => {
          reject(err)
          this.$notify.error({ title: '保存异常！', message: err || '' })
        })
      })
    }
  }
}
</script>

<style scoped>
</style>
